package comWorld.action.social;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import comWorld.social.SocialManage;
import comWorld.user.UserStatus;

/**
 * Servlet implementation class Follow
 */
@WebServlet("/action/social/follow")
public class Follow extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Follow() {
        super();
    }

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		int followId = Integer.valueOf(request.getParameter("followId"));
		UserStatus userStatus = (UserStatus) request.getSession().getAttribute("visitorStatus");
		SocialManage.addFriend(userStatus.getId(), followId);
		response.getWriter().print("2");
	}

}
